<%@ page pageEncoding="UTF-8"%>

<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<div>
	<logic:present name="search_vo" property="trainStationName">
		<c:choose>
			<c:when test="${search_vo.trainStationName eq ''}">
				<p align="center" style="margin: 20px 0;">请在查询框内输入车站信息...</p>
			</c:when>
			<c:otherwise>
				<p class="nav_result">
					<logic:present name="result.page">
						经过<label class="redb" style="margin:0 5px;">${search_vo.trainStationName}</label>的车次查询结果如下：
					</logic:present>
					<logic:notPresent name="result.page">
						经过<label class="redb" style="margin:0 5px;">${search_vo.trainStationName}</label>的车次没有找到：
					</logic:notPresent>
				</p>
				<table width="100%" cellpadding="0" cellspacing="0" border="1" style="text-align:center;" class="datagrid">
					<thead>
						<tr> 
							<td>车次</td>
							<td>类型</td>
							<td>始发站</td>
							<td>始发时间</td>
							<td>到站时间</td>
							<td>查询站</td>
							<td>开车时间</td>
							<td>终点站</td>
							<td>终点运行</td>
							<td>里程</td>
						</tr>
					</thead>
					<tbody>
						<logic:present name="result.page">
							<logic:iterate name="result.page" property="items" id="entity" indexId="idx">
								<tr <c:if test="${idx % 2 == 1}">bgcolor="#fafbf5"</c:if>>
									<td><a style="text-decoration: underline;" href="app/train/search?code=${entity.trainNumberEncode}">${entity.trainNumber}</a></td>
									<td>${entity.trainType}</td>
									<td><a style="text-decoration: underline;" href="app/train/search?station=${entity.trainStationStarting}">${entity.trainStationStarting}</a></td>
									<td>${entity.trainTimeDeparture}</td>
									<td>${entity.trainTimeArrival}</td>
									<td>${search_vo.trainStationName}</td>
									<td>${entity.trainTimeDeparture}</td>
									<td><a style="text-decoration: underline;" href="app/train/search?station=${entity.trainStationTerminating}">${entity.trainStationTerminating}</a></td>
									<td>${entity.trainRuntime}</td>
									<td>${entity.trainRange}</td>
								</tr>
							</logic:iterate>
						</logic:present>
						<logic:notPresent name="result.page">
							<tr><td colspan="10">很抱歉，您查询的车站暂时没有(可能停运).</td></tr>
						</logic:notPresent>
					</tbody>
					<logic:present name="result.page">
						<tfoot>
							<tr>
								<td colspan="10">
									<logic:notEmpty name="result.page">
										<bean:define id='total' name="result.page" property="totalPage" />
										<bean:define id='currentPage' name="result.page" property="currentPage" />
										<div class="pagination">
											<div class="pageopr">
												<a href="javascript:switch_page(1);" title="首页" class="loca_btn">首页</a>
												<a href="javascript:switch_page(<c:out value='${currentPage - 1 eq 0 ? 1 : currentPage - 1}' />);" title="上一页" class="loca_pre">上一页</a>
												<a href="javascript:switch_page(<c:out value='${currentPage + 1 gt total ? total : currentPage + 1}' />);" title="下一页" class="loca_next">下一页</a>
												<a href="javascript:switch_page(<bean:write name='result.page' property='totalPage' />);" title="尾页" class="loca_btn">尾页</a>
											</div>
											<div class="lstinfo">
												<span>数据：<logic:present name="result.page"><bean:write name="result.page" property="totalCount" /></logic:present><logic:notPresent name="result.page">0</logic:notPresent>条</span>
												<span>第<input type="text" class="pageinput text" id="rdpage" value="<bean:write name='result.page' property='currentPage' />" size="5" />/<label id='totalPage'><logic:present name="result.page"><bean:write name="result.page" property="totalPage" /></logic:present><logic:notPresent name="result.page">1</logic:notPresent></label>页</span>
												<span><a href="javascript:switch_page();" title="转到" class="loca_btn">转到</a></span>
											</div>
										</div>
										<b class="clear"></b>
									</logic:notEmpty>
								</td>
							</tr>
						</tfoot>
					</logic:present>
				</table>
			</c:otherwise>
		</c:choose>
	</logic:present>
</div>